<?php include_once './application/views/sys_admin/common/header.php';  ?>
<div class=" definewidth m20">
	<table class="table table-bordered table-hover definewidth m10">
		 <thead>
		    <tr>
		       <th><strong>编号</strong></th>
				<th><strong>标的名称</strong></th>
				<th><strong>标的类型</strong></th>
				<th><strong>金额</strong></th>
				<th><strong>年利率</strong></th>
				<th><strong>标的期限</strong></th>
				<th><strong>(预约)发标时间</strong></th>
				<th><strong>审核进度</strong></th>
				<th><strong>标的状态</strong></th>
				<th><strong>操 作 </strong></th>
		    </tr>
		 </thead>
		 <?php foreach($borrow_list as $key=>$borrow){?>
			  <tr id ="shen_<?php $borrow['id']; ?>" >
				<td><?php echo $borrow['id'];?></td>
				<td><a href="/sys_admin/borrow/borrow_view/<?php echo $borrow['id'];?>"><?php echo $borrow['title'];?></a></td>
				<td><?php echo $borrow_type[$borrow['ftype']];?></td>
				<td><?php echo number_format($borrow['account'],2);?></td>
				<td><?php echo $borrow['apr'];?>%</td>
				<td><?php if($borrow['is_day'] == 1){echo $borrow['time_limit_day'].'天';}else{ echo $borrow['time_limit'].' 个月';}?></td>
				<td><?php if($borrow['auto_verify_time'] > 0){echo date('Y-m-d H:i',$borrow['auto_verify_time']);}?></td>
				<!-- by liub 20141127 修改 -->
			  	<?php  if($borrow['is_verify'] == 1 && $borrow['is_check']==1){?>
					<td>
						<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }elseif($borrow['is_verify'] == 1 && $borrow['is_check']==0){?>
					<td>
					<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }elseif($borrow['is_verify'] == 0 && $borrow['is_check']==0){?>
					<td>
					<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }elseif($borrow['is_verify'] == 2 && $borrow['is_check']==0){?>
					<td>
					<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }elseif($borrow['is_verify'] == 0 && $borrow['is_check']==1){?>
					<td>
						<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }elseif($borrow['is_verify'] == 0 && $borrow['is_check']==2){?>
					<td>
						<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
			  	<?php }elseif($borrow['is_verify'] == 1 && $borrow['is_check']==2){?>
					<td>
						<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }else{?>
					<td>
						未知进度</td>
				<?php }?>
				
				<td><?php echo $borrow_status[$borrow['fstatus']];?></td>
				<td id="chebiao_<?php echo $borrow['id'];?>" >
					<?php if($borrow['fstatus'] == 0 || $borrow['fstatus'] < 1){ ?>
					<?php 
						//TODO by liub 20141128 修改显示条件
					if($fshow == 'again' ){?>
						<?php if($borrow['is_check']!=1){?>
							<a href="/sys_admin/borrow/verify_again_view/<?php echo $borrow['id'];?>">复检</a>
							<a href="/sys_admin/borrow/edit_view/<?php echo $borrow['id'];?>">修改</a> 
						<?php }else{?>
						<?php }?>
						<a href="javascript:if(confirm('你确定撤回？')){withdraw(<?php echo $borrow['id'];?>);}">撤回</a>
					<?php }elseif($fshow == 'first' ){?>
						<?php if($borrow['is_verify']!=1){?>
							<a href="/sys_admin/borrow/verify_view/<?php echo $borrow['id'];?>" >初检</a>
							<a href="/sys_admin/borrow/edit_view/<?php echo $borrow['id'];?>" >修改</a> 
						<?php }else{?>
						<?php }?>
					<?php } elseif($fshow == 'publish' ){?>
						<a href="javascript:if(confirm('你确定手动上线吗？')){borrowpublish(<?php echo $borrow['id'];?>);}">上线</a>
					<?php }}?>
				</td>
			  </tr>
			  <?php }?>
			  <tr>
			  	<td colspan="14"  class="page"><?php echo $this->pagination->create_links();?></td>
			  </tr>
	</table>
</div>
<div id="dialog" title="系统提示" style="display:none;">
<div id="msg" style="text-align:center;color:red">&nbsp;</div>
</div>

<script>
function borrowpublish(borrow_id){
	$.ajax({
		type: "get",
		url: "/sys_admin/cron/borrowpublish/"+borrow_id,
		success: function(msg){
			$("#dialog" ).dialog();
			if(msg == 1){
				$("#msg").html("上线成功！");
				$("#shen_"+borrow_id).hide();
			}else{
				$("#msg").html("上线失败，请联系管理员");
			}
			setTimeout(function(){
				$("#dialog" ).dialog("close");
			},3000);
		},
		dataType: "text"
	});
}
</script>
